#ifndef CDATABASE_H
#define CDATABASE_H

#include "../libpq/libpq-fe.h"
#include "../Models/MCharacter.h"
#include "../Models/MClient.h"

#include <QObject>
#include <QMap>
#include <QMessageBox>

class CDataBase : public QObject
{
    Q_OBJECT

    private:
        char* host;
        char* port;
        char* dbname;
        char* user;
        char* password;

        QMessageBox *message_box1;
        QMessageBox *message_box2;
        QMessageBox *message_box3;
        QMessageBox *message_box4;
        QMessageBox *message_box5;

    signals:
        void ERROR_CONNECTION();

    public slots:
        bool open();
        void close();

        bool exec(QString query);

        bool authenticate(QString _username, QString _password);
        bool add_log_chat(QString _username, QString _content);
        bool add_log_connection(QString _username, QString _password, int _succeed);
        QList<MCharacter *> get_characters(MClient* client);


    public:
        CDataBase();
        ~CDataBase();
};

#endif // CDATABASE_H
